﻿using System;
using UnityEngine;

// Token: 0x0200011F RID: 287
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
public class CameraSetRenderTexture : MonoBehaviour
{
	// Token: 0x170000BA RID: 186
	// (get) Token: 0x06000696 RID: 1686 RVA: 0x00026FDC File Offset: 0x000251DC
	public RenderTexture RendTex
	{
		get
		{
			return this.rendTex;
		}
	}

	// Token: 0x170000BB RID: 187
	// (get) Token: 0x06000697 RID: 1687 RVA: 0x00026FE4 File Offset: 0x000251E4
	private Camera Cam
	{
		get
		{
			if (this._cam == null)
			{
				this._cam = base.GetComponent<Camera>();
			}
			return this._cam;
		}
	}

	// Token: 0x06000698 RID: 1688 RVA: 0x0002700C File Offset: 0x0002520C
	private void OnPreRender()
	{
		if (this.rendTex == null || this.rendTex.width != Screen.width || this.rendTex.height != Screen.height)
		{
			this.Cam.targetTexture = null;
			UnityEngine.Object.DestroyImmediate(this.rendTex);
			this.rendTex = new RenderTexture(Screen.width, Screen.height, 0);
			this.rendTex.hideFlags = HideFlags.HideAndDontSave;
		}
		this.Cam.targetTexture = this.rendTex;
	}

	// Token: 0x06000699 RID: 1689 RVA: 0x000270A0 File Offset: 0x000252A0
	private void OnDisable()
	{
		this.Cam.targetTexture = null;
		UnityEngine.Object.DestroyImmediate(this.rendTex);
	}

	// Token: 0x04000659 RID: 1625
	private RenderTexture rendTex;

	// Token: 0x0400065A RID: 1626
	private Camera _cam;
}
